package test.client.thread.message;

import test.client.thread.ClientThread;

/*
 * This thread logs in to Openfire server and do nothing. This is designed for messaging test. 
 */
public class ClientPersistentLoginThread extends ClientThread {
	@Override
	public void run() {
		try {
			this.login();
			
			while (this.getStatus() == Status.RUNNING) {
				Thread.sleep(5000);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		finally {
			this.disconnect();
			log.debug(this.getUsername() + " thread done.");
			
			this.setStatus(Status.COMPLETED);
		}
	}
	
	public static void main(String[] args) {
		ClientPersistentLoginThread thread = new ClientPersistentLoginThread();
		thread.setUsername("user000000");
		thread.setPassword("welcome1");
		
		new Thread(thread).start();
		try {
			Thread.sleep(3000);
			thread.stop();
		}
		catch (Exception e) {
			e.printStackTrace();
		}		
	}
}
